<?php /* D:\phpStudy\PHPTutorial\WWW\laravel-admin\resources\views/admin/goods/goodsLeaseSet.blade.php */ ?>
<div id="app">
    <section class="content-header">
        <h1>
            <small>商品租期设置</small>
        </h1>

    </section>

    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-info">
                    <div class="box-header with-border">


                        <div class="box-tools">
                            <div class="btn-group pull-right" style="margin-right: 5px">
                                <a href="/admin/goods/goodsLease?goods_id=<?php echo e($goods['goods_id'], false); ?>" class="btn btn-sm btn-default" title="商品租期展示"><i class="fa fa-list"></i><span class="hidden-xs">&nbsp;商品租期展示</span></a>
                            </div>
                        </div>


                        <span>
    <a class="btn btn-sm btn-primary grid-refresh" title="刷新"><i class="fa fa-refresh"></i><span class="hidden-xs"> 刷新</span></a>
    <a class="btn btn-sm btn-primary" onclick="javascript:history.go(-1);" title="返回"> <span class="hidden-xs"> 返回</span></a>
  </span>
                    </div>
                    <!-- /.box-header -->
                    <!-- form start -->
                    <form id="addForm" action="/admin/goods/goodsAdd" method="post" accept-charset="UTF-8" class="form-horizontal" enctype="multipart/form-data" pjax-container>
                        <div class="box-body">
                            <div class="fields-group">

                                <div class="form-group  ">
                                    <label for="cha_id" class="col-sm-2  control-label">商品信息</label>
                                    <div class="col-sm-8">
                                        商品名称：<?php echo e($goods['goods_name'], false); ?>  <br />
                                        商品价格：<?php echo e($goods['goods_price'], false); ?><br />
                                        商品进货价：<?php echo e($goods['goods_purchase_price'], false); ?><br />
                                        商品官方价：<?php echo e($goods['goods_official_price'], false); ?>


                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="sku" class="col-sm-2  control-label">商品sku</label>
                                    <div class="col-sm-8">
                                        <?php if($sku): ?>
                                            <?php $__currentLoopData = $sku; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>

                                                <label class="radio-inline">
                                                    <input type="radio" onclick="getMoneys(this)" name="sku" value="<?php echo e($v['id'], false); ?>" class="minimal "   />&nbsp;
                                                </label>
                                                <input type="text" class="form-control" readonly value="商品属性规格：【<?php echo e($v['sku_str'], false); ?>】  商品总价：<?php echo e($v['goods_price'], false); ?> , 商品官方价：<?php echo e($v['goods_official_price'], false); ?> , 进货价：<?php echo e($v['goods_purchase_price'], false); ?>">
                                                <br />
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        <?php endif; ?>

                                    </div>
                                </div>




                                <div class="form-group  ">
                                    <label for="rent_price" class="col-sm-2  control-label">总租金</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input style="width: 120px" type="text" id="rent_price" name="rent_price" value="<?php echo e($goods['goods_price'], false); ?>" class="form-control rent_price" placeholder="输入 商品总价" />
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="deposit_price" class="col-sm-2  control-label">押金</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input style="width: 120px" type="text" id="deposit_price" name="deposit_price" value="<?php echo e($goods['goods_price'], false); ?>" class="form-control deposit_price" placeholder="输入 商品总价" />
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="buyout_price" class="col-sm-2  control-label">买断金</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            <input style="width: 120px" type="text" id="buyout_price" name="buyout_price" value="<?php echo e($buyMoney, false); ?>" class="form-control buyout_price" placeholder="输入 商品总价" />
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group  ">
                                    <label for="term_num" class="col-sm-2  control-label">租期期数</label>
                                    <div class="col-sm-8">
                                        <div class="input-group">
                                            <input   style="width: 100px;display: inline-block" type="text" id="term_num" name="term_num" value="" class="form-control term_num"   />

                                         <button type="button"  style="margin-top:5px;color:#f9f9f9;width:80px;position:relative;float: right;background:#3b8ab8;height:30px;border-radius: 5px;padding:3px;border: 1px solid #3b8ab8;" onclick="setZuqi()">设置</button>

                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label for="term_num" class="col-sm-2  control-label"></label>
                                    <div class="col-sm-8" id="zuqi_html" style="border: 1px solid #a1cbef;padding:5px;">

                                    </div>
                                </div>

                            </div>
                        </div>
                        <!-- /.box-body -->

                        <div class="box-footer">
                            <?php echo csrf_field(); ?>
                            <input type="hidden" id="goods_id" name="goods_id" value="<?php echo e($goods['goods_id'], false); ?>">
                            <div class="col-md-2">
                            </div>
                            <div class="col-md-8">
                                <div class="btn-group pull-right">
                                    <button type="button" onclick="tijiao()" class="btn btn-primary">提交</button>
                                </div>

                                <div class="btn-group pull-left">
                                    <button type="reset" class="btn btn-warning">重置</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>

            </div></div>
    </section>
</div>
<script data-exec-on-popstate>
    $(function () {
        $("input.img").fileinput({"overwriteInitial":true,"initialPreviewAsData":true,"browseLabel":"\u6d4f\u89c8","showRemove":false,"showUpload":false,"dropZoneEnabled":false,"deleteExtraData":{"goods_img_list":"_file_del_","_file_del_":"","_token":"Kq6b1qbgSwE02ACOgZOsO9QeD99PSWROQgk10d1w","_method":"PUT"},"deleteUrl":"http:\/\/www.laras.com\/admin\/goods\/","allowedFileTypes":["image"]});
        $('.after-submit').iCheck({checkboxClass:'icheckbox_minimal-blue'}).on('ifChecked', function () {
            $('.after-submit').not(this).iCheck('uncheck');
        });

        $('.sku').iCheck({checkboxClass:'icheckbox_minimal-blue'});
        $('.rent_price').inputmask({"alias":"currency","radixPoint":".","prefix":"","removeMaskOnSubmit":true});
        $('.deposit_price').inputmask({"alias":"currency","radixPoint":".","prefix":"","removeMaskOnSubmit":true});
        $('.buyout_price').inputmask({"alias":"currency","radixPoint":".","prefix":"","removeMaskOnSubmit":true});
        $('.term_num:not(.initialized)')
            .addClass('initialized')
            .bootstrapNumber({
                upClass: 'success',
                downClass: 'primary',
                center: true
            });

        var cha_id=$("#cha_id").val();
        if(cha_id>0){
            getPid(ob,cha_id);
        }

        //刷新
        $('.grid-refresh').on('click', function() {
            $.pjax.reload('#pjax-container');
            toastr.success('刷新成功 !');
        });
    });

    function setZuqi(){
        var num=$("#term_num").val();
        var price=$("#rent_price").val();
        if(num>0){
            $.ajax({
                url:'/admin/goods/getZuqiHtml',
                type:'get',
                data:{term_num:num,rent_price:price},
                dataType:'json',
                success:function (m) {
                    if(m.status==1){
                        $("#zuqi_html").html(m.data.html);
                    }
                }
            });
        }
    }

    function getMoneys(e) {
         var id=$(e).val();
        $.ajax({
            url:"/admin/goods/getLeaseMoneys",
            type:'post',
            data:{id:id,_token:LA.token},
            dataType:'json',
            success:function(m){
                if(m.status==1){
                    toastr.success(m.message);
                    $("#buyout_price").val(m.data.buyout_price);
                    $("#rent_price").val(m.data.rent_price);
                    $("#deposit_price").val(m.data.deposit_price);
                }else{
                    toastr.error(m.message);
                }
            }
        });
    }

    function tijiao(){
        var data=new FormData($("#addForm")[0]);
        var goods_id=$("#goods_id").val();
        $.ajax({
            url:"/admin/goods/goodsLeaseSet",
            type:'post',
            data:data,
            dataType:'json',
            processData: false,
            contentType: false,
            success:function(m){
                if(m.status==1){
                    toastr.success(m.message);
                    window.location.href='/admin/goods/goodsLease?goods_id='+goods_id;
                }else{
                    swal(m.message, '', 'error');
                }
            }
        });
    }
</script>